#ifndef  _EPOLL_H_
#define  _EPOLL_H_

#include "../define/define.h"
#include "./log.h"

class epoll_single
{
public:
   epoll_single(uint32 curfds)
   {
	  m_handle = epoll_create(MAXEPOLLSIZE);  
	  m_curfds = curfds;

	  m_log = new logfile("epoll_single");
   }

   ~epoll_single()
   {
	   delete m_log;
   }

   bool set(uint32 handle,uint32 enent_type)
   {
	   m_event.events = enent_type;
	   m_event.data.fd = handle;
      
	   if(epoll_ctl(m_handle, EPOLL_CTL_ADD, handle, &m_event) ==-1 )
	   {
		   return false;
	   }

       return true;
   }

   uint32  wait(epoll_event* events)
   {
	  int  nfds = epoll_wait(m_handle, events, m_curfds, 1); 

	  if(nfds < 0)
		  return 0;
	  
	  return  nfds;
   }

   bool  del(uint32 handle)
   {
	   if( epoll_ctl(m_handle,EPOLL_CTL_DEL,handle,&m_event) == -1)
	   {
		   return false;
	   }
	   
	   return true;
   }

private:

	logfile*  m_log;
	uint32 m_handle;
	struct epoll_event m_event;
	uint32 m_curfds;

};
#endif
